var xhr;
function checkUsername() {

    var username = document.getElementById('username').value;
    xhr = new XMLHttpRequest();

    xhr.open("GET","usernameIsExist?username="+username,true);
    xhr.onreadystatechange = process;
    xhr.send(null);


}

function process() {
    var msg = document.getElementById('isExistInfo');

    if (xhr.readyState == 4){
        if (xhr.status == 200){
            var respomseInfo = xhr.responseText;

            if (respomseInfo == 'Exist'){
                msg.innerHTML = '<font color="red">用户名不可用</font>';
            }else if (respomseInfo == 'Not Exist'){

                msg.innerHTML='<font color="green">用户名可用</font>';
            }
            else if (respomseInfo == "null")
                msg.innerHTML = '<font color="red">请输入用户名</font>';

        }
    }
    else msg.innerText = xhr.readyState;
}